import request from '@/utils/request'

// 获取新闻列表
export function getNewList(params) {
  return request({
    url: '/newslist',
    method: 'get',
    params
  })
}

// 获取单条新闻
export function getNews(id) {
  return request({
    url: `/news/${id}`,
    method: 'get'
  })
}

// 添加新闻
export function addNews(params) {
  return request({
    url: '/news',
    method: 'post',
    data: params
  })
}

// 修改新闻
export function editNews(id, params) {
  return request({
    url: `/news/${id}`,
    method: 'put',
    data: params
  })
}

// 上传图片
export function onUpdated(params) {
  return request({
    url: '/upload/news',
    method: 'post',
    'Content-Type': 'multipart/form-data',
    data: params
  })
}

// 删除新闻
export function deleteNews(id) {
  return request({
    url: `/news/${id}`,
    method: 'delete'
  })
}
